home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE22
/
EX11.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-29
|
3KB
|
66 lines
#include <genstub.c>
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
switch ( LOWORD( wParam ) )
{
case IDM_TEST:
{
TCHAR szBuffer[128];
TCHAR szDateBuffer[128];
TCHAR sLongDateFormat[65];
HDC hDC = GetDC( hWnd );
// Save long date format.
GetLocaleInfo( LOCALE_USER_DEFAULT, DATE_LONGDATE,
sLongDateFormat, 64 );
// Show date and time.
GetDateFormat( LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
NULL, NULL, szDateBuffer, 127 );
TextOut( hDC, 0, 0, szBuffer, wsprintf( szBuffer,
"The date is %s", szDateBuffer ) );
GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE,
NULL, NULL, szDateBuffer, 127 );
TextOut( hDC, 0, 20, szBuffer, wsprintf( szBuffer,
"The long date is %s", szDateBuffer ) );
GetTimeFormat( LOCALE_USER_DEFAULT, TIME_FORCE24HOURFORMAT,
NULL, NULL, szDateBuffer, 127 );
TextOut(hDC, 0, 40, szBuffer, wsprintf( szBuffer,
"The time is %s", szDateBuffer ) );
// Change long date format.
memcpy( szBuffer,
"dd\0\" of \"\0MMM\0\" of \"\0YYYY\0\0", 27 );
SetLocaleInfo( LOCALE_USER_DEFAULT, DATE_LONGDATE,
szBuffer );
// Get formatted date in new locale format.
GetDateFormat( LOCALE_USER_DEFAULT, DATE_LONGDATE,
NULL, NULL, szDateBuffer, 127 );
TextOut( hDC, 0, 60, szBuffer, wsprintf( szBuffer,
"The long date is %s", szDateBuffer ));
ReleaseDC( hWnd, hDC );
// Restore long date format.
SetLocaleInfo( LOCALE_USER_DEFAULT,
DATE_LONGDATE, sLongDateFormat );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return( DefWindowProc( hWnd, uMsg, wParam, lParam ) );
}
return( NULL );
}